package gtkwire.gobject;

import java.util.Hashtable;
import gtkwire.*;
import gtkwire.widget.utils.GtkStock;

public abstract class GtkTreeModel extends GObject
{
	protected GType[] columnTypes = null;

	private boolean lastOpOut = false;

	private int stamp = 0;

	private static Hashtable<Integer,GtkCellDataFunc> dfuncs = new Hashtable<Integer,GtkCellDataFunc>();

	protected GtkTreeModel( int type )
	{
		super(type);
	}

	public GType getColumnType( int column )
	{
		return columnTypes[ column ];
	}

	public Object getValue( GtkTreeRowIter iter, int columnIndex )
	{
		return null;
	}

	public Object[] getRowValues(  GtkTreeRowIter iter )
	{
		return null;
	}

	/**
	* Initializes iter with the first iterator in the tree
	* (the one at the path "0") and returns TRUE. Returns FALSE if the tree is empty.
	*/
	public GtkTreeRowIter getFirstIter()
	{
		return new GtkTreeRowIter( "0", this );
	}

	public GtkTreeRowIter getRowIter( int index, int level, int[] indices )
	{
		return null;
	}

	public GtkTreeRowReference getNewRowRef( GtkTreeRow iter )
	{
		return null;
	}

	public int getChildCount( GtkTreeRowIter iter )
	{
		return -1;
	}

	public int currentStamp()
	{
		return stamp;
	}

	public boolean lastOpOutOfRange()
	{
		boolean retBool = lastOpOut;
		lastOpOut = false;
		return retBool;
	}

	//----------------------------------------------------- DATA FUNC CELL RENDERING

	public static void addDataFuncFilter( int dfunc_id, GtkCellDataFunc df )
	{
		System.out.println("cell_rend_id" + dfunc_id );
		dfuncs.put( new Integer( dfunc_id ), df );
	}	

	//--- CAllback from native.
	private static void cellRenderCallBack( int dfunc_id, String path )
	{
		GtkCellDataFunc df = dfuncs.get( new Integer(dfunc_id ));
		df.cellRenderCallBack( dfunc_id, path );
	}
	//------------------------------------------------------- NATIVE INTERFACE
	//--- get
	public native Object getValue( int model_id, int column, String path);

	//--- set
	public native void setIntLS( int list_id,  String path, int column_id, int value );
	public native void setStringLS( int list_id,  String path, int column_id, String value);
	public native void setBooleanLS( int list_id,  String path, int column_id, boolean value);
	public native void setGObjectLS( int list_id,  String path, int column_id, int g_id);

	//--- cell renderer
	protected native static void set_cell_property( String property, int property_type, String value );
	protected native static void registerDataFuncN( int tree_column_id, int cell_rend_id, int datafunc_id );
}//end class